<template>
  <div class="top-wrapper">
    <div class="top">
      <span class="type" :class="{current: type === 'hot'}" @click="change('hot')">正在热卖</span>
      <span class="type" :class="{current: type === 'sub'}" @click="change('sub')">新品预热</span>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'ListTop',
    data() {
      return {
        type: 'hot'
      }
    },
    methods: {
      change(type) {
        this.type = type
        this.$emit('change', type)
      }
    }
  }
</script>

<style lang="scss" scoped>
  .top-wrapper {
    border-bottom: 1px solid #ccc;
    margin-bottom: 0.2rem;
  }
  .top {
    margin: 0 auto;
    width: 3rem;
    height: 0.8rem;
    line-height: 0.8rem;
    text-align: center;
    font-size: 0.32rem;
    .type {
      display: inline-block;
      margin-right: 0.15rem;
      height: 100%;
      font-size: 0.3rem;
      &:nth-child(2) {
        margin: 0;
      }
      &.current {
        position: relative;
        color: #e83225;
      }
      &.current::after {
        content: '';
        position: absolute;
        bottom: 0;
        left:50%;
        transform: translateX(-50%);
        width: 0.72rem;
        height: 2px;
        background: #e83225;
      }
    }
  }
</style>
